<?php
	require_once "../config/app.config.php";
	$Entity = new Entity(1);
    $EntityDefinition = array();
	$EntityDefinition['Store'] = $Entity->Store->JsonColumns;
	$EntityDefinition['ColumnModel'] = $Entity->ColumnModel->JsonColumns;
//								"[ 
//							        {name: 'IDpresident', type: 'int', mapping: 'IDpresident'},
//							        {name: 'FirstName', type: 'string', mapping: 'firstname'},
//							        {name: 'LastName', type: 'string', mapping: 'lastname'},
//							        {name: 'IDparty', type: 'int', mapping: 'IDparty'},
//							        {name: 'PartyName', type: 'string', mapping: 'name'},
//							        {name: 'TookOffice', type: 'date', mapping: 'tookoffice'},
//							        {name: 'LeftOffice', type: 'date', mapping: 'leftoffice'},
//							        {name: 'Income', type: 'float', mapping: 'income'}
//							      ]";
//	$EntityDefinition['ColumnModel'] = "
//										[{
//									        header: '#',
//									        readOnly: true,
//									        dataIndex: 'IDpresident', // this is where the mapped name is important!
//									        width: 50,
//									        hidden: false
//									      },{
//									        header: 'First Name',
//									        dataIndex: 'FirstName',
//									        width: 150,
//									        editor: new Ext.form.TextField({  // rules about editing
//									            allowBlank: false,
//									            maxLength: 20,
//									            maskRe: /([a-zA-Z0-9\s]+)$/   // alphanumeric + spaces allowed
//									          })
//									      },{
//									        header: 'Last Name',
//									        dataIndex: 'LastName',
//									        width: 150,
//									        editor: new Ext.form.TextField({
//									          allowBlank: false,
//									          maxLength: 20,
//									          maskRe: /([a-zA-Z0-9\s]+)$/
//									          })
//									      },{
//									        header: 'ID party',
//									        readOnly: true,
//									        dataIndex: 'IDparty',
//									        width: 50,
//									        hidden: true                      // we don't necessarily want to see this...
//									      },{
//									        header: 'Party',
//										   	dataIndex: 'PartyName',
//										   	width: 150,
//										   	editor: new Ext.form.ComboBox({
//										         typeAhead: true,
//										         triggerAction: 'all',
//										         store:new Ext.data.SimpleStore({
//										         fields:['partyValue', 'partyName'],
//										         data: [['1','No Party'],['2','Federalist'],['3','Democratic-Republican'],['4','Democratic'],['5','Whig'],['6','Republican']]
//										                }),
//										         mode: 'local',
//										         displayField: 'partyName',
//										         valueField: 'partyValue',
//										         listClass: 'x-combo-list-small'
//										      })
//						
//									      },{
//									        header: 'Income',
//									        dataIndex: 'Income',
//									        width: 150,
//									        renderer: function(v){ return '$ ' + v; },   // we tell Ext how to display the number
//									        editor: new Ext.form.NumberField({
//									          allowBlank: false,
//									          decimalSeparator : ',',
//									          allowDecimals: true,
//									          allowNegative: false,
//									          blankText: '0',
//									          maxLength: 11
//									          })
//									      }]
//										";
	// Encodes a SQL array into a JSON formated string
	$jsonresult = JEncode($EntityDefinition);
	echo '('.$jsonresult.')';
	function JEncode($arr){
	    if (version_compare(PHP_VERSION,"5.2","<"))
	    {    
	        require_once("./JSON.php"); //if php<5.2 need JSON class
	        $json = new Services_JSON();//instantiate new json object
	        $data=$json->encode($arr);  //encode the data in json format
	    } else
	    {
	        $data = json_encode($arr);  //encode the data in json format
	    }
	    return $data;
	}
?>